home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Info 1994 March
/
Internet Info CD-ROM (Walnut Creek) (March 1994).iso
/
networking
/
ip
/
ka9q
/
xobbs.arc
/
makhdrfil.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-05-03
|
2KB
|
65 lines
/*MAKHDRFIL.C Makes new header file for XOBBS W2XO, 4-4-89 */
/*Version 1.3 */
#define MAIN 1
#include "xobbs.h"
main()
{
FILE *fp;
int i,hfd,fd2;
char s[30],*bp,*cp;
char hdr[130],c,filnam[15];
char hdr_num[130];
char buf[4096];
char htmpl[30];
getconfig();
sprintf(prinbuf,"ls %s | sort -rn",maildir);
fp=popen(prinbuf,"r"); /*get the mail directory*/
i=0;
while(((c=fgetc(fp)) != EOF) && (i < 4095)) /*read in the names*/
buf[i++]=c;
buf[i]='\0'; /*terminate the names*/
pclose(fp); /*close the pipe*/
bp=buf; /*point to the first name in the buffer*/
sprintf(prinbuf,"mv %s %soldhdr",hdrfile,homedir);
system(prinbuf);
if((hfd=open(hdrfile,O_WRONLY | O_CREAT,0x1b6)) < 0){
sprintf(prinbuf,"mkhdrfil: Can't open temp header file\n");
perror(prinbuf);
}
/*loop and service each file in the mail directory*/
for(;;){
if(*bp=='\n') bp++; /*if sitting on a lf, increment*/
if(*bp=='\0') break; /*if end of string, leave*/
cp=filnam; /*point to the filname space*/
while(*bp != '\n') *cp++ = *bp++; /*read up to next lf into filnam*/
*cp='\0'; /*terminate the filname*/
sprintf(prinbuf,"%s%s",maildir,filnam); /*file name in s*/
if((fd2=open(prinbuf,O_RDONLY)) < 0){
sprintf(prinbuf,"makhdrfil: Cant open message file no.%s\n",filnam);
perror(prinbuf);
}
else
{
fgetline(fd2,hdr);
sprintf(hdr_num,"%-5s %-85.85s\n",filnam,hdr);
write(hfd,hdr_num,92); /*write out the header file line*/
close(fd2);
}
}
close(hfd); /*close the header file*/
}